<?php
/**
 * 用户提现操作
 */
namespace app\api\model;
use app\common\model\MemberEntrust as MemberEntrustModel;
use think\facade\Queue;

class MemberEntrust
{
    public function __construct(MemberEntrustModel $MemberEntrustModel)
    {
        $this->MemberEntrustModel = $MemberEntrustModel;
    }

    /**
     * 添加用户交易记录
     * @param $mid  用户ID
     * @param $money    金额
     * @param $num 数量
     * @param $currency 币种 1:USDT 2:ADC
     * @param $transaction_state 1买 2卖
     * @param $entrust_state 1：委托中2：委托完成3：撤销委托
     * @param $price_hook 1：价格钩子
     * @param $u_buy_price 1:购买价格
     * @return int|string
     */
   public function add_entrust($mid,$money,$num,$currency,$transaction_state,$entrust_state,$price_hook = 0,$u_buy_price = 0)
   {

       $data = [
           'mid'   =>  $mid,
           'money'   =>  $money,
           'currency'  =>  $currency,
           'num'  =>  $num,
           'transaction_state' =>  $transaction_state,
           'entrust_state' =>  $entrust_state,
           'price_hook' =>  $price_hook,
           'u_buy_price' =>  $u_buy_price
       ];

       return $this->MemberEntrustModel->add_entrust($data);

       /*$data['id'] =$id;

       $jobHandlerClassName = 'app\job\Task@fire';

       $jobQueueName = 'entrust';

       $isPushed = Queue::push($jobHandlerClassName, $data, $jobQueueName);*/

   }


    /**
     * 数据列表
     */
    public function entrust_list($where,$page,$limit)
    {
        return $this->MemberEntrustModel->entrust_list($where,$page,$limit);
    }
    /**
     * 查询数据
     */
    public function git_data($id,$mid)
    {
        return $this->MemberEntrustModel->git_data($id,$mid);
    }

    /**
     * 修改数据
     */
    public function up_data($git_data)
    {
        $data['id'] = $git_data['id'];
        $data['entrust_state'] = 3;
        return $this->MemberEntrustModel->up_data($data);
    }

}